[#import "/framework/JGP.htm"  as JGP]
<!--
项目   jgp-cloud-parent
作者   LOUFEI [Gavin]
时间   2019/4/1
-->
[@JGP.head "Title"/]
[@JGP.body]
    <jgp-div _row="['30','*']" _runit="px">
        <div slot="1-1">
            <jgp-btn _fn="addJob">添加任务</jgp-btn>
        </div>
        <jgp-grid slot="2-1" _url="/timing/job-api-ctl/list-jobs"
                  _record_tools="[{'icon':'edit','tip':'修改','fn':'editJob'},
                      {'icon':'plus','tip':'启动','fn':'startJob'},
                      {'icon':'plus','tip':'重启','fn':'restartJob'},
                      {'icon':'plus','tip':'停止','fn':'stopJob'},
                      {'icon':'trash-o','tip':'删除','fn':'removeJob'}]">
            <jgp-grid-col _name="started" _transform_value="transformValueFn"></jgp-grid-col>
        </jgp-grid>
    </jgp-div>
[/@JGP.body]

[@JGP.foot]
    <script>
        function addJob() {
            var config = {
                url:'/timing/job-ctl/add-job',
                callback:function (result) {
                    console.log(result);
                }
            }
            JGP.$dialog(config);
        }
        function editJob(args){
            var config = {
                url:'/timing/job-ctl/edit-job/'+args.back.record.id,
                callback:function (result) {
                    if(result){
                        location.reload();
                    }
                }
            }
            JGP.$dialog(config);
        }

        function startJob(args){
            JGP.$post('/timing/job-api-ctl/start-job',{
                jobId:args.back.record.id
            },function (result) {
                console.log('result',result);
            })
        }

        function restartJob(args){
            JGP.$post('/timing/job-api-ctl/restart-job',{
                jobId:args.back.record.id
            },function (result) {
                console.log('result',result);
            })
        }

        function stopJob(args){
            JGP.$post('/timing/job-api-ctl/stop-job',{
                jobId:args.back.record.id
            },function (result) {
                console.log('result',result);
            })
        }

        function removeJob(args){
            JGP.$post('/timing/job-api-ctl/remove-job',{
                jobId:args.back.record.id
            },function (result) {
                console.log('result',result);
            })
        }

        function transformValueFn(args){
            return args.back.value?'已启动':'停止'
        }

    </script>
[/@JGP.foot]